<template>
    <div id="app">
        <div class="on">
            <div id="bread">
                <el-breadcrumb separator-class="el-icon-arrow-right">
                    <el-breadcrumb-item :to="{ path: '/manage/index' }">首页</el-breadcrumb-item>
                    <el-breadcrumb-item>公司审核</el-breadcrumb-item>
                </el-breadcrumb>
            </div>
        </div>
        <div class="companyList">
        <el-table
                :data="tableData"
                border
                style="width:1200px;margin-top: 10px;"
        >
            <el-table-column
                    fixed
                    label="序号"
                    width="150">
                <template slot-scope="scope">
                    {{scope.$index+1}}
                </template>
            </el-table-column>
            <el-table-column
                    prop="positionType.typeName"
                    label="企业行业类型"
                    width="120">
            </el-table-column>
            <el-table-column
                    prop="name"
                    label="公司名称"
                    width="120">
            </el-table-column>
            <el-table-column
                    prop="province.provName"
                    label="省份"
                    width="120">
            </el-table-column>
            <el-table-column
                    prop="city.cityName"
                    label="城市"
                    width="120">
            </el-table-column>
            <el-table-column
                    prop="district.districtName"
                    label="行政区"
                    width="120">
            </el-table-column>
            <el-table-column
                    prop="address"
                    label="地址"
                    width="300">
            </el-table-column>
            <el-table-column
                    prop="email"
                    label="电子邮箱"
                    width="300">
            </el-table-column>
            <el-table-column
                    prop="enrollTime"
                    label="企业注册时间"
                    width="300">
            </el-table-column>
            <el-table-column
                    prop="legalRepresentative"
                    label="法人代表"
                    width="300">
            </el-table-column>
            <el-table-column
                    prop="registeredCapital"
                    label="注册资本"
                    width="300">
            </el-table-column>
            <el-table-column
                    prop="creationDate"
                    label="成立日期"
                    width="300">
            </el-table-column>
            <el-table-column
                    fixed="right"
                    label="操作"
                    width="100">
                <template slot-scope="scope">
                    <!--                    <el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button>-->
                    <!--                    <el-button type="text" size="small">编辑</el-button>-->
                    <el-button type="success" icon="el-icon-check" circle size="mini" title="通过" @click="passCompany(scope.$index, scope.row)"></el-button>
                    <el-button type="danger" icon="el-icon-delete" circle size="mini" title="不通过" @click="delCompany(scope.row)"></el-button>
                </template>
            </el-table-column>
        </el-table>
            <el-pagination
                    background
                    layout="prev, pager, next"
                    :page-size="pageInfo.pageSize"
                    :total="pageInfo.total"
                    @current-change="handlePageChange"
            >
            </el-pagination>
        </div>

    </div>
</template>

<script>
    export default {
        name: "auditCompanyList",
        data(){
            return{
                pageNum: 1,
                tableData:[],
                pageInfo:{}
            }
        },
        methods:{
            getAllAuditCompaniesByPages(){
                this.$axios.get("manage/getAllAuditCompaniesByPageNum",{params:{pageNum:this.pageNum}}).then(response=>{
                    console.log(response.data);
                    this.tableData=response.data.companies.list;
                    this.pageInfo=response.data.companies;
                });
            },
            handlePageChange(pageNum){
                this.pageNum=pageNum;
                this.getAllAuditCompaniesByPages();
            },
            passCompany(index,row){
                this.$axios.get("manage/passOneCompany",{params:{id:row.id}}).then(response=>{
                    this.getAllAuditCompaniesByPages();
                });
            },
            delCompany(row){
                if (confirm("确认拒绝这家公司的申请吗"))
                {
                    this.$axios.get("manage/deleteOneCompany",{params:{id:row.id}}).then(response=>{
                        this.getAllAuditCompaniesByPages();
                    })
                }
            }
        },
        created() {
            this.getAllAuditCompaniesByPages();
        }
    }
</script>

<style scoped>
    .on{
        margin-top: 30px;
        margin-left: 30px;
    }
    .companyList{
        margin-top: 30px;
        margin-left: 30px;
    }
</style>